import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:livan_ui/values/livan_colors.dart';
import 'package:livan_ui/values/livan_fonts.dart';

///appbar封装
AppBar LivanAppBar({
  String? title,
  Color color = const Color(0xFF66696D),
  Color backgroundColor = Colors.white,
  Color foregroundColor = const Color(0xff5c5f63),
  List<Widget>? actions,
  PreferredSizeWidget? bottom,
}) {
  return AppBar(
    elevation: 0,
    centerTitle: true,
    systemOverlayStyle: const SystemUiOverlayStyle(
        statusBarBrightness: Brightness.dark
    ),
    leading: Builder(builder: (BuildContext context){
      return GestureDetector(
        child: Container(
          color: Colors.transparent,
          padding: EdgeInsets.only(left: 30.w),
          alignment: Alignment.centerLeft,
          child: Icon(Icons.arrow_back_ios, size: 30, color: ColorsValue.textGrey,),
        ),
        onTap: () async{
          await Navigator.of(context).maybePop();
        },
      );
    },
    ),
    backgroundColor: backgroundColor,
    foregroundColor: foregroundColor,
    title: Text(
      title ?? "",
      style: TextStyle(
        color: color,
        fontSize: Font.font16,
        fontWeight: FontWeight.normal,
      ),
    ),
    actions: [
      ...?actions,
    ],
    bottom: bottom,
  );
}

extension Custome on AppBar {
  AppBar custom() {
    return AppBar();
  }
  test() {}
}
